<template>
	<view>
		<!-- 资讯板块 -->
		<scroll-view scroll-x>
			<view class="news_wrap">
				<view 
					class="_item" 
					v-for="(item, index) in newsTypes" 
					:key="index"
					:class="{'active': newsIndex===index}"
					@click="changeNewsType(item, index)"
				>
					{{item.name}}
				</view>
			</view>
		</scroll-view>
		
		<!-- 大图板块 （推荐类） -->
		<view class="index_ban_wrapper">
			 <u-swiper
				:list="bannerList"
				@click="bannerRoute"
				keyName="image"
				showTitle
				height="180"
			/>
		</view>
		
		<view class="">
			<view class="news_item" v-for="(item, index) in 3" :key="index">
				<view class="_left">
					<view class="_title">每个组件，包括如下几个部分：以组件名称为标记的开始标签和结束标签、组件内容、组件属性、组件属性值</view>
					<view class="_time">2022-10-10 20:02:03</view>
				</view>
				<image class="_img" mode="aspectFill" src="https://img2.baidu.com/it/u=4134404395,864195599&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=666"></image>
			</view>
		</view>
		
		
		<!-- 焦点板块 -->
		<view class="index-title-cell">
			<view class="_title">焦点板块</view>
		</view>
		<view class="focus_wrapper">
			<view class="_item" v-for="(item,index) in 6" :key="index">
				<image class="_img" mode="aspectFill" src="https://img2.baidu.com/it/u=4134404395,864195599&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=666"></image>
				<view class="_bottom">
					<view class="_title">每个组件，包括如下几个部分：以组件名称为标记的开始标签和结束标签、组件内容、组件属性、组件属性值</view>
					<view class="_time">2022-10-10 20:02:03</view>
				</view>
			</view>
		</view>
		
		
		
		<!-- 推荐板块 -->
		<view class="index-title-cell">
			<view class="_title">推荐板块</view>
		</view>
		<view class="recommend_wrapper">
			<view class="_item" v-for="(item,index) in 4" :key="index">
				<image class="_img" mode="aspectFill" src="https://img2.baidu.com/it/u=4134404395,864195599&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=666"></image>
				<view class="_bottom">
					<view class="_title">每个组件，包括如下几个部分：以组件名称为标记的开始标签和结束标签、组件内容、组件属性、组件属性值</view>
					<view class="_time">2022-10-10 20:02:03</view>
				</view>
			</view>
		</view>
		
		
		
		
		<!-- 浮动个人中心按钮 -->
		<cover-view class="float_member" @click="routerPage">
			<cover-image class="_icon" src="../../static/img/member.png"></cover-image>
		</cover-view>
		
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				newsIndex: 0,
				newsTypes: [
					{name: '要闻',id: '0'},
					{name: '热点',id: '1'},
					{name: '昆明',id: '2'},
					{name: '漫画',id: '3'},
					{name: '图片',id: '4'},
					{name: '政治',id: '5'},
					{name: '国际',id: '6'},
					{name: '国内',id: '7'},
					{name: '视频',id: '8'},
					{name: '军事',id: '9'},
				],
				bannerList: [{
					image: 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
					title: '昨夜星辰昨夜风，画楼西畔桂堂东',
				},{
					image: 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
					title: '身无彩凤双飞翼，心有灵犀一点通'
				},{
					image: 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
					title: '谁念西风独自凉，萧萧黄叶闭疏窗，沉思往事立残阳'
				}],
			}
		},
		
		
		methods: {
			
			// 切换类型
			changeNewsType(item, index) {
				this.newsIndex = index;
				console.log(item.name);
			},
			
			// 跳转登录页
			routerPage(){
				uni.navigateTo({
					url: "/pages/login/login"
				})
			},
			
			bannerRoute(e) {
				console.log(e);
			}
			
		}
	}
</script>

<style lang="scss" scoped>
	.index_search{
		padding: 0 30rpx;
	}
	.news_wrap{
		display: flex;
		background: #fff;
		padding: 0 10rpx;
		width: fit-content;
		._item{
			padding: 0 20rpx;
			color:#666;
			font-size: 28rpx;
			display: flex;
			justify-content: center;
			line-height: 90rpx;
			white-space: nowrap;
			&.active{
				font-size: 38rpx;
				font-weight: bold;
				color: #000;
			}
		}
	}
	
	.index_ban_wrapper{
		padding: 20rpx 30rpx 30rpx 30rpx;
		background: #fff;
		border-bottom: 1px solid #e8e8e8;
	}
	
	.news_item{
		background: #fff;
		display: flex;
		justify-content: center;
		padding: 30rpx;
		border-bottom: 1px solid #eee;
		&:last-child{
			border-bottom: none
		}
		._left{
			flex: 1;
			margin-right: 25rpx;
			display: flex;
			justify-content: space-between;
			flex-direction: column;
			._title{
				font-weight: bold;
				font-size: 32rpx;
				height: 100rpx;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				overflow: hidden;
				text-overflow: ellipsis;
				line-height: 50rpx;
			}
			._time{
				font-size: 28rpx;
				color: #999;
			}
		}
		._img{
			width: 300rpx;
			height: 200rpx;
		}
	}
	
	.index-title-cell{
		height: 120rpx;
		margin-top: 30rpx;
		padding: 0 30rpx;
		display: flex;
		align-items: center;
		background: #fff;
		._title{
			font-size: 38rpx;
			font-weight: bold;
		}
	}
	
	.focus_wrapper{
		display: flex;
		flex-wrap: wrap;
		padding: 0 0 0 30rpx;
		._item{
			width: 50%;
			box-sizing: border-box;
			padding: 0 30rpx 50rpx 0;
			._img{
				width: 100%;
				height: 200rpx;
				display: block;
				margin-bottom: 15rpx;
			}
			._bottom{
				margin-right: 25rpx;
				display: flex;
				justify-content: space-between;
				flex-direction: column;
				._title{
					font-weight: bold;
					font-size: 32rpx;
					height: 100rpx;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
					text-overflow: ellipsis;
					line-height: 50rpx;
					margin-bottom: 10rpx;
				}
				._time{
					font-size: 28rpx;
					color: #999;
				}
			}
		}
	}
	
	.recommend_wrapper{
		display: flex;
		flex-wrap: wrap;
		padding: 0 0 0 30rpx;
		._item{
			width: 50%;
			box-sizing: border-box;
			padding: 0 30rpx 50rpx 0;
			._img{
				width: 100%;
				height: 200rpx;
				display: block;
				margin-bottom: 15rpx;
			}
			._bottom{
				margin-right: 25rpx;
				display: flex;
				justify-content: space-between;
				flex-direction: column;
				._title{
					font-weight: bold;
					font-size: 32rpx;
					height: 100rpx;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
					text-overflow: ellipsis;
					line-height: 50rpx;
					margin-bottom: 10rpx;
				}
				._time{
					font-size: 28rpx;
					color: #999;
				}
			}
		}
	}
	
	.float_member{
		position: fixed;
		right: 40rpx;
		bottom: 10vh;
		border-radius: 50%;
		background: $uni-color-primary;
		width: 120rpx;
		height: 120rpx;
		z-index: 10;
		display: flex;
		justify-content: center;
		align-items: center;
		overflow: hidden;
		._icon{
			width: 60rpx;
			height: 60rpx;
		}
	}
	
	
</style>
